from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
import unittest


class MyTestCase(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        service = Service(executable_path="../../driver/geckodriver.exe")
        cls.driver = webdriver.Firefox(service=service)

    def test_firefox(self):
        self.driver.get("https://www.baidu.com")
        text = self.driver.find_element(By.XPATH, "//input[@id='kw']")
        text.send_keys("selenium", Keys.RETURN)

    @classmethod
    def tearDownClass(cls) -> None:
        # cls.driver.close()
        cls.driver.quit()


if __name__ == '__main__':
    unittest.main()
